package test.cntLoad;


import javax.microedition.midlet.MIDletStateChangeException;


import test.MusicChoiceState;
import test.NetHandler;
import test.testDialog.TestStateFactor;
import uuengine.component.FlushState;
import uuengine.connect.*;
import uuengine.util.Log;
import uuengine.engine.Load;
import uuengine.engine.ResLoad;
import uuengine.engine.StateManager;
import uuengine.engine.StateWapper;
import uuengine.engine.UUMIDlet;

public class MyMIDlet extends UUMIDlet{
	protected void startApp() throws MIDletStateChangeException 
	{
		super.startApp();
		StateManager.setStateFactor(new TestStateFactor());

		CntHandler handler=new NetHandler(new SocketConnect(),"192.168.99.201:8000");
	
		FlushState flush=new FlushState();
		
		ResLoad resload=new ResLoad();
		resload.addEventListener(flush);
		
		FlushListener listener =new FlushListener();
		flush.addEventListener(listener);
		

		Load load=new IntLoad(handler);
		resload.setLoad(load);
		new Thread(resload).start();

		StateManager.setCurrState(flush);
		
		
		mainCanvas=new StateWapper(midlet,getDisplay());
		mainCanvas.addHandler(handler);
		this.getDisplay().setCurrent(mainCanvas);
		mainCanvas.start(100L);
//		Log.clearLog();
	}
	
}
